//
//  DB_TableViewModel.m
//  RacMVVM
//
//  Created by 崔博 on 2018/11/27.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "DB_TableViewModel.h"
@interface DB_TableViewModel()
@property (nonatomic, strong, readwrite) RACCommand *requestRemoteDataCommand;
@end
@implementation DB_TableViewModel
- (void)initialize
{
    [super initialize];
    self.page = 1;
    self.perPage = 100;
    self.shouldPullToRefresh = YES;
    self.shouldInfiniteScrolling = YES;
    @weakify(self)
    self.requestRemoteDataCommand = [[RACCommand alloc] initWithSignalBlock:^(NSNumber *page) {
        @strongify(self)
        return [[self requestRemoteDataSignalWithPage:page.unsignedIntegerValue]
                takeUntil:self.rac_willDeallocSignal];
    }];
    
    [[self.requestRemoteDataCommand.errors
      filter:[self requestRemoteDataErrorsFilter]]
     subscribe:self.errors];
}

- (BOOL (^)(NSError *error))requestRemoteDataErrorsFilter {
    return ^(NSError *error) {
        return YES;
    };
}
- (id)fetchLocalData {
    return nil;
}

- (RACSignal *)requestRemoteDataSignalWithPage:(NSUInteger)page {
    return [RACSignal empty];
}

@end
